ScriptX names are case insensitive. That is, upper and lower case letters are treated the same. However, ScriptX remembers the case used the first time a new name appears and uses that case whenever it displays that name.
Throughout the Kaleida Technical Reference Series, the following case conventions are used:
appendNew
beginDecompressSeq
SequencePlayer
KeyedLinkedList
ScriptX defines about a hundred reserved words that cannot be used as lexical names. (They can be used to name keyword arguments for functions.) For a complete list of reserved words, see Table A-3 on page 232.
Names must begin with an alphabetic character or an underscore ( _
). They can contain only uppercase and lowercase letters (A-Z, a-z), numbers, or the underscore character. Names cannot contain spaces, tabs, special characters, or non-alphanumeric characters such as symbols and punctuation. They can be up to 256 characters in length.
Here are some examples of valid names:
foo
mylist
_x
HugePulsingCreatureFromTheCratersOfVenus
bignum4500
oswald_acted_alone
Here are some examples of names that are invalid:
23skidoo -- invalid, because it starts with a number
curses@(*&#!*@& -- invalid, because it contains symbols
spread out -- interpreted as two names, because it contains a space
aïda -- contains an accented or inflected character
NameClass
instances which exist at run time. Name literals evaluate to NameClass
objects.
@foo
intern NameClass ("foo" + "bar")
Name literals follow the same upper and lower case conventions as lexical names. Here are some more examples and uses of name literals:
@utterly_undefined_thing
prin variableThing @normal debug -- used as a label for an argument
animals := #(@snake:"cobra", @bird:"sparrow", @fish:"guppy")
Name literals form a proper set. Multiple occurrences of a name literal with the same sequence of characters always evaluate to the same object. For example, the names @lefthanded
, @LeftHanded
, and @LEFTHANDED
are not merely equal-they represent the same object. Name literals can be stored and compared more efficiently than strings, since multiple instances of strings may contain the same sequence of characters but are still different objects.
Name literals are useful as labels to make your scripts more readable. For example, if a function has an argument that is always one of three values, you can use name literals for those values instead of using numbers or strings. Additionally, name literals can be used as keys in key-value pairs, or anywhere else you need a valueless label in a script. Name literals are used extensively in this way by the ScriptX core classes.
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.